using UnityEngine;

public class PlayerAIState_Offense_FindPos : State<PlayerAI>
{
	public static PlayerAIState_Offense_FindPos instance;

	private PlayerAIState_Offense_FindPos()
	{
	}

	public static PlayerAIState_Offense_FindPos getInstance()
	{
		if (instance == null)
		{
			instance = new PlayerAIState_Offense_FindPos();
		}
		return instance;
	}

	public override void enter(PlayerAI owner)
	{
		base.enter(owner);
		owner.offense_findpos_targetpos = owner.getAvailableOffensePos();
	}

	public override void fixedUpdate(PlayerAI owner)
	{
		base.fixedUpdate(owner);
		owner.player.do_run();
		if (MathHelper.getSqrDistance(owner.player.getPosition(), owner.offense_findpos_targetpos) < 4f)
		{
			if (GameHelper.MoveTo(owner.player, owner.offense_findpos_targetpos, owner.player.getMoveSpeed(), isLookAtTargetPos: false))
			{
				owner.do_offense_getloose();
				owner.time_Stop = Random.Range(1f, 5f);
			}
			if (owner.player.team.IsAnyOneControlBall())
			{
				owner.player.LookAtSmooth(owner.player.team.getPlayer_ControlBall().getPosition());
			}
		}
		else if (GameHelper.MoveTo(owner.player, owner.offense_findpos_targetpos, owner.player.getMoveSpeed(), isLookAtTargetPos: true))
		{
			owner.do_offense_getloose();
			owner.time_Stop = Random.Range(1f, 5f);
		}
	}
}
